﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ePioneer_web_ep_question_userques : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            bd(1);
        }
      
    }

    private void bd(int page)
    {

        CMSModel.CMSEntities dal = DAL.DBManager.GetCmsEmtity();
        string strUserid = "1";// Request["userid"].ToString();
        int iUnSolveNum = dal.ePioneer_Question.Where(x => x.UserId == strUserid && x.IsClose == 0).Count();
        int iSolveNum = dal.ePioneer_Question.Where(x => x.UserId == strUserid && x.IsClose == 1).Count();

        question_solve_num.InnerHtml = iSolveNum.ToString();
        question_unsolve_num.InnerHtml = iUnSolveNum.ToString();



        int iSolve = -1;   //查处全部，解决和未解决
        if (Request["solve"] != null)
        {
            //传入值为1则为
            iSolve = Convert.ToInt32(Request["solve"]);
            if (iSolve == 0)
            {
                div_solve.Attributes.Add("class", "user_que");
                div_unsovle.Attributes.Add("class", "user_sque");
            }
            else
            {
                div_solve.Attributes.Add("class", "user_sque");
                div_unsovle.Attributes.Add("class", "user_que");
            }
        }
        else
        {
            div_solve.Attributes.Add("class", "user_que");
            div_unsovle.Attributes.Add("class", "user_que");
        }


        var ep_question_list = dal.ePioneer_Question.Where(x => x.UserId == strUserid && x.IsClose != iSolve);//.OrderByDescending(x => new { x.IsClose, x.CreateDate });

        AspNetPager1.RecordCount = ep_question_list.Count();
        AspNetPager1.CurrentPageIndex = page;
        ep_question_list = ep_question_list.OrderByDescending(x => new { x.IsClose, x.CreateDate }).Skip((page - 1) * AspNetPager1.PageSize).Take(AspNetPager1.PageSize);

    
        Repeater1.DataSource = ep_question_list;
        Repeater1.DataBind();

       

    
    }

    public int GetPage()
    {
        return AspNetPager1.CurrentPageIndex;
    }

    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        bd(AspNetPager1.CurrentPageIndex);
       
    }

    //中文转换
    public string GetIsClose(object iclose)
    {
        if (int.Parse(iclose.ToString())==1)
        {
            return "已解决";
        }
        else
            return "未解决";
    }   
}